{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        <div class="ibox-content">
            <div class="row">
                <!--搜索框开始-->
                <div class="col-sm-12">
                    <div class="layui-form layui-form-item">

                        <div class="layui-input-inline" style="margin-top: 10px;">
                            <input type="text"  name="start_time" onfocus="wk.lay_date(this);"  class="layui-input layer-date search" placeholder="支付时间-起" />
                        </div>

                        <div class="layui-input-inline" style="margin-top: 10px;">
                            <input type="text"  name="end_time" onfocus="wk.lay_date(this);"  class="layui-input layer-date search" placeholder="支付时间-止" />
                        </div>

                        <div class="layui-input-inline" style="margin-top: 10px;">
                            <button class="layui-btn" lay-submit="" lay-filter="LAY-search">立即搜索</button>
                            <button class="layui-btn layui-btn-normal" id="empty" lay-submit="" lay-filter="LAY-search">
                                重置
                            </button>
                        </div>
                    </div>
                </div>
                <!--搜索框结束-->
                <!--操作框开始-->
                <div class="col-sm-12">
                    <div class="input-group" >
                        <button class="btn btn-primary" type="button" onclick="wk.layer_show('添加子商户', '{:url('mchAdd')}');">
                            <i class="fa fa-plus"></i> 添加子商户
                        </button>
                    </div>
                </div>
                <!--操作框结束-->

            </div>

            <div class="hr-line-dashed"></div>

            <div class="example-wrap">
                <div class="example">
                    <table class="layui-hide" id="test" lay-filter="testReload"></table>

                    <!--状态显示模板-->
                    <script type="text/html" id="statBar">
                        {{# if(d.mch_status == 1){ }}
                        <span style="color: green">启用</span>
                        {{# } }}
                        {{# if(d.mch_status == 2){ }}
                        <span style="color: red">冻结</span>
                        {{# } }}
                    </script>
                    <script type="text/html" id="defaultBar">
                        {{# if(d.mch_default == 1){ }}
                        <span style="color: green">默认</span>
                        {{# } }}
                        {{# if(d.mch_default == 2){ }}
                        <span style="color: red">非默认</span>
                        {{# } }}
                    </script>
                    <!--操作模板-->
                    <script type="text/html" id="opeBar">
<!--                        <a href="javascript:;" onclick="wk.layer_show('订单详情', '{:url('orderDetail')}?mch_id={{d.mch_id}}')" class="btn btn-warning btn-xs m-r-xs" title="订单详情">订单详情</a>-->
                        {{# if(d.mch_default == 2 && d.mch_status == 1) { }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.mch_id}}','{:url('setDefault')}','确认设为默认吗？')" class="btn btn-info btn-xs m-r-xs" title="设为默认">设为默认</a>
                        {{# } }}
                        {{# if(d.mch_status == 1) { }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.mch_id}}','{:url('setStatus')}','确认冻结吗？')" class="btn btn-danger btn-xs m-r-xs" title="冻结">冻结</a>
                        {{# } }}
                        {{# if(d.mch_status == 2) { }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.mch_id}}','{:url('setStatus')}','确认启用吗？')" class="btn btn-info btn-xs m-r-xs" title="启用">启用</a>
                        {{# } }}
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
    //layui渲染数据表格
    layui.use('table', function () {
        var table = layui.table
            , form = layui.form;
        table.render({
            elem: '#test'
            , url: '{:url("Submch/index")}'
            , response: {
                statusCode: 220 //成功的状态码，默认：0
            }
            , page: true
//            , size: 'lg' //sm小尺寸的表格 lg大尺寸
            , cellMinWidth: 150
            , limits: [5, 10, 15, 20, 25, 30]
            , limit: "{:config('pages')}"
            , loading: true
            , id: 'testReload'
            , cols: [[
                // {type: 'checkbox', fixed: 'left'}
                  {field: 'mch_id', width: 60, title: 'ID', align: 'center'}
                , {field: 'mch_code', width: '', title: '子商户号', align: 'center'}
                , {field: 'total_price', width: 220, title: '收款总额', align: 'center'}
                , {field: 'mch_status', width: 120, title: '状态', align: 'center', toolbar: '#statBar'}
                , {field: 'mch_default', width: 120, title: '是否默认', align: 'center', toolbar: '#defaultBar'}
                , {fixed: 'right', width: 280, title: '操作', align: 'center', toolbar: '#opeBar'}
            ]]
            , done: function (res, curr, count) {
                $('.img-circle').viewer({
                    url: 'data-original',
                });
            }
        });


        $('.layuiBtn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        var getIds = function () {
            var ids = [];
            var checkStatus = table.checkStatus('testReload')
                , data = checkStatus.data;
            $.each(data, function (index, item) {
                ids.push(item['mch_id'])
            });
            return ids;
        }
    });
</script>
</body>
</html>